<script>
import config from './config'
import store from '@/store'
import { getToken } from '@/utils/auth'
export default {
  onLaunch: function () {
    this.initApp()
    console.log('App Launch')

  },
  methods: {
    // 初始化应用
    initApp() {
      // 初始化应用配置
      this.initConfig()
      // 检查用户登录状态
      //#ifdef H5
      this.checkLogin()
      // #endif
      

    },

    checkLogin() {
      this.globalData.deviceId = this.getUrlCode('deviceId');
      uni.setStorageSync("open_id", this.getUrlCode('openId'));
      if (/MicroMessenger/.test(window.navigator.userAgent)) {
		    // alert('微信');
        this.globalData.browserClient = 'MicroMessenger';
		    } else if (/AlipayClient/.test(window.navigator.userAgent)) {
		    //alert('支付宝');
         this.globalData.browserClient = 'AlipayClient';
		    } else {
		    // alert('其他浏览器');
        this.globalData.browserClient = 'other';
			  // this.$tab.reLaunch('/pages/massageChair/scanError')

		}
    },

    // 正则匹配请求地址中的参数函数
    getUrlCode(name) {
      return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ''])[1].replace(/\+/g, '%20')) || null
    },

    initConfig() {
      this.globalData.config = config;
    },


  }
}
</script>

<style lang="scss">
@import '@/static/scss/index.scss'
</style>
